-- pumpkin_explode
-- created by zhuangsl
-- 爆裂南瓜自爆效果

return {
    apply = function(prop, baseValue)
        return baseValue;
    end,

    -- 死亡触发
    trigger = function(who, prop, arg)
        if who.type ~= OBJECT_TYPE_USER then
            return;
        end

        -- 计算伤害
        local dungeonId = DungeonM.getDungeonId();
        if dungeonId == nil then
            dungeonId = ME.user.dbase:query("currentDungeon");
        end
        local layerFix = DungeonAreaM.query(dungeonId,"layer_fix");
        local floor = DungeonM.currentLayer();
        local force = floor + 4 + prop[3] + 16;
        local damage = FormulaM.invoke("CALC_BIG_DIVISION", math.pow(force, 3), layerFix + 60, 20000);

        for pos = 1, GRID_SIZE do
            local grid = DungeonM.getGridByPos(pos);
            local monster = grid.monster;

            -- 在场上的怪物
            if grid:isOpened() and monster and not monster:isDead() then
                SkillM.initSequence(who, monster, 0);
                SkillM.getSequence(monster):start(who, monster, 0);
                CombatM.doDamage(who, monster, damage, 0);
            end
        end
    end,

    record = function(target, prop, path)
        return false;
    end
};
